package agrep4me;

abstract class States {
	protected static int nlongs = -1;
	protected static int card = -1;

	static States setCard(int card) {
		States.card = card;
		States.nlongs = (card + 63) / 64;
		// System.err.println("nlongs=" + States.nlongs) ;
		if (nlongs <= 1)
			return new IStates();
		else
			return new LStates();
	}

	int card() {
		return card;
	}

	int nbytes() {
		return (card + 7) / 8;
	}

	abstract States empty();

	abstract int getByte(int i);

	abstract void assign(States from);

	abstract States copy();

	abstract void clear();

	abstract void add(int i);

	abstract boolean mem(int i);

	abstract void or(States s);

	abstract void and(States s);

	abstract void shift();

	abstract boolean equals(States s);

	public String toString() {
		StringBuffer r = new StringBuffer();
		boolean fst = true;
		r.append("{");
		for (int i = 0; i < card; i++) {
			if (mem(i)) {
				if (fst) {
					fst = false;
					r.append(i);
				} else {
					r.append(", " + i);
				}
			}
		}
		r.append("}");
		return r.toString();
	}
}
